<? 
include"../inc/config.inc.php";
if($_POST[MODE]=="ADD")
{
    $std_id         =$_POST['std_id'];
    $std_name       =$_POST['std_name'];
    $std_surname    =$_POST['std_surname'];
    $birth_day      =$_POST['birth_day'];
    $personal_id    =$_POST['personal_id'];
    $std_address    =$_POST['std_address'];
    $std_phone      =$_POST['std_phone'];
    $level_id       =$_POST['level_id'];
    $year_id        =$_POST['year_id'];
    $parent         =$_POST['parent'];

    $sql = "insert into student(std_id,std_name,std_surname,std_birth,personal_id,std_address,std_phone,level_id,year_id,parent)"
        ."values('$std_id','$std_name','$std_surname','$birth_day','$personal_id','$std_address','$std_phone','$level_id','$year_id','$parent')";

    mysql_query($sql) or die (mysql_error());
    echo"<meta http-equiv='refresh' content='0;URL=student.php'>";
}
if($_GET[MODE]=="DEL")
{
    $std_id=$_GET['std_id'];
    $std_name=$_GET['std_name'];
    $std_surname=$_GET['std_surname'];
    $personal_id=$_GET['personal_id'];
    $std_address=$_GET['std_address'];
    $std_phone=$_GET['std_phone'];
    $level_id=$_GET['level_id'];
    $year_id=$_GET['year_id'];
    $parent=$_GET['parent'];
    $sql="delete from student where std_id='$std_id'";
    mysql_query($sql) or die (mysql_error());
    echo"<meta http-equiv='refresh' content='0;URL=student.php'>";
}
if($_POST[MODE]=="EDIT")
{
    $std_id=$_POST['std_id'];
    $std_name=$_POST['std_name'];
    $std_surname=$_POST['std_surname'];
    $birth_day      =$_POST['birth_day'];
    $personal_id=$_POST['personal_id'];
    $std_address=$_POST['std_address'];
    $std_phone=$_POST['std_phone'];
    $level_id=$_POST['level_id'];
    $year_id=$_POST['year_id'];
    $parent=$_POST['parent'];
    $sql = "UPDATE student set std_id='".$std_id."',std_name='".$std_name."',"
          ."std_surname='".$std_surname."',std_birth='".$birth_day."',personal_id='".$personal_id."' ,std_address='".$std_address."',"
          ."std_phone='".$std_phone."',level_id='".$level_id."',year_id='".$year_id."',parent='".$parent."' where std_id='".$std_id."'";
    mysql_query($sql) or die(mysql_error());
    echo"<meta http-equiv='refresh' content='0;URL=student.php'>";
}
if($_GET['mode']=='update')
{
    $stat = $_GET['stat'];
    $id = $_GET['id'];
    $sql = "UPDATE student set status = '".$stat."' WHERE std_id = '".$id."'";
    mysql_query($sql);
    echo"<meta http-equiv='refresh' content='0;URL=student.php'>";
}
?>
